package com.pug.controller;

import com.pug.service.PugEmailService;
import com.pug.vo.ToEmail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

/**
 * @author 飞哥
 * @Title: 学相伴出品
 * @Description: 飞哥B站地址：https://space.bilibili.com/490711252
 * 记得关注和三连哦！
 * @Description: 我们有一个学习网站：https://www.kuangstudy.com
 * @date 2022/4/21$ 20:39$
 */
@RestController
public class SendEmailController {

    @Autowired
    private PugEmailService pugEmailService;

    @GetMapping("/sendemail")
    public String commonEmail(ToEmail toEmail) {
        toEmail.setSubject("注册邮件");
        return pugEmailService.sendEmail(toEmail) ? "success" : "fail";
    }


    @GetMapping("/sendemail2")
    public String htmlEmail(ToEmail toEmail) {
        return pugEmailService.sendEmailHTML(toEmail) ? "success" : "fail";
    }

}
